package  
{
  import flash.display.Sprite;
  import flash.events.Event;
  import mge.graph.Edge;
	/**
   * ...
   * @author ivan
   */
  public class VisualEdge extends Sprite
  {
    
    public function VisualEdge(edge:Edge) 
    {
      this.edge = edge;
      addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
    }
    
    private function onAddedToStage(e:Event):void
    {
      removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
      
      addEventListener(Event.ENTER_FRAME, draw);
      
      this.mouseEnabled = true;
      this.buttonMode = true;
    }
        
    private function draw(e:Event):void
    {
      x = edge.source.x;
      y = edge.source.y;
      
      graphics.clear(); 
      graphics.lineStyle(1);
      graphics.beginFill(0x000000, 0.5);
      graphics.moveTo(0, 0);
      graphics.lineTo(edge.target.x - edge.source.x, edge.target.y - edge.source.y);
      graphics.endFill();
    }

    
    public var edge:Edge;
    
  }

}